home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 10 / FM Towns Free Software Collection 10.iso / tos_updt / fmcity / palcom / auto / script / apsel.mx next >
Text File  |  1995-04-13  |  26KB  |  872 lines

  1. //--------------------------------------------------------------------------//
  2. //                        PALCOM V2.1 L10                        //
  3. //                自動通信:アクセスポイント選択ダイアログスクリプト            //
  4. //                                                                            //
  5. //                                        CopyRight(C) 1994/10/20                //
  6. //                                FUJITSU PERSONAL COMPUTER SYSTEMS LIMITED    //
  7. //                                        written by C-cube Soft T.Nakamura    //
  8. //--------------------------------------------------------------------------//
  9. event    @OPEN.EXTERN {
  10.     AUTO.setDialogReturn( -1 );
  11.  
  12.     //---   登録アクセスポイントファイルのオープン   ---//
  13.     $TrdId = #FALSE;
  14.     sys.global( $TrdId );
  15.     $TrdId = trd.init( 9120, -1 );
  16.     $Path = str.join([$$DIR.STANDARD, "PUBLIC\\APUSER.TRD"],"" );
  17.     sys.global( $Path );
  18.     sys.global( $ApList );
  19.     sys.global( $ApDispList );
  20.     $ApList     = [];
  21.     $ApDispList = [];
  22.     if( file.exist( $Path ) == #TRUE ) {
  23.         trd.load( $TrdId, $Path );
  24.  
  25.         //---   リストデータの設定   ---//
  26.         $ApList     = AUTO.getAPlist( $TrdId, -1 );    // AP のリスト設定
  27.         $ApDispList = Auto.getAPdispList( -1 );        // 表示文字列リストの設定
  28.     }
  29.     if( list.size( $ApList ) == 0 ) {
  30.         //---   アクセスポイントが1件も登録されていない場合は   ---//
  31.         //---                     直接登録ダイアログを表示する   ---//
  32.         if( Auto.apSel() == -1 ) {
  33.             AUTO.setDialogReturn( 0 );
  34.             return;
  35.         }
  36.         $$USER.DEFINED.9 = 1;
  37.     }
  38.  
  39.     //---   リストの反転項目番号の取得   ---//
  40.     $cnt = 1;
  41.     $defList = [1];
  42.     foreach( $a, $ApList ) {
  43.         if( list.get1st( list.getLast( $a )) == $$USER.DEFINED.9 ) {
  44.             $defList = [$cnt];
  45.             exit;
  46.         }
  47.         $cnt = $cnt + 1;
  48.     }
  49.  
  50.     //---   ボタンの設定   ---//
  51.     $newBtnId = dialog.makeButton( 1, "アクセスポイントの作成", 0,      0 );
  52.     $selBtnId = dialog.makeButton( 1, "登録",                   0,      0 );
  53.     $delBtnId = dialog.makeButton( 1, "削除",                   0, 0x007F );
  54.     $edtBtnId = dialog.makeButton( 1, "編集",                   0,      0 );
  55.     $setBtnId = dialog.makeButton( 1, "設定",                   0, 0x8012 );
  56.     $canBtnId = dialog.makeButton( 1, "取消",                   0, 0x8011 );
  57.  
  58.     //---   ダイアログリストの設定   ---//
  59.     $dialogList = ["アクセスポイントの設定", 0, -1, -1, $setBtnId,
  60.             ["", 1028,      [76,10,0], $ApDispList,   $defList    ],
  61.             ["", $canBtnId, [0],       [""],          [""]        ],
  62.             ["", $setBtnId, [0],       [""],          [""]        ],
  63.             ["", $edtBtnId, [0],       [""],          [""]        ],
  64.             ["", $delBtnId, [0],       [""],          [""]        ],
  65.             ["", $selBtnId, [0],       [""],          [""]        ],
  66.             ["", $newBtnId, [0],       [""],          [""]        ]];
  67.  
  68.     $exitFlg = 0;
  69.     $uFlg    = #FALSE;
  70.     loop {
  71.         //---   ダイアログの表示   ---//
  72.         sys.pushCursor( 80 );
  73.         dialog.open( $dialogList );
  74.         sys.popCursor();
  75.  
  76.         //---   ボタンの処理   ---//
  77.         $btnId = list.get1st( $$DIALOG.RETURN );
  78.         $no    = list.get1st( list.getNth( $$DIALOG.RETURN, 2 ));
  79.  
  80.         //---   選択されていなくては実行出来ない物のチェック   ---//
  81.         if(( $btnId == $delBtnId )||( $btnId == $edtBtnId )||
  82.            ( $btnId == $setBtnId )) {
  83.             if( $no == -1 ) {
  84.                 continue;
  85.             }
  86.         }
  87.  
  88.         //---   押されたボタンに応じた処理を実行   ---//
  89.         $no2 = #FALSE;
  90.         table( $btnId ) {
  91.             else        { $ret = -1; $exitFlg = 1;    }
  92.             $canBtnId    { $ret =  0; $exitFlg = 1;    }    // 取消
  93.             $newBtnId    { $no2 = Auto.apEdt(  -1 );    }    // 作成
  94.             $selBtnId    { $no2 = Auto.apSel();        }    // 登録
  95.             $delBtnId    { Auto.apDel( $no );        }    // 削除
  96.             $edtBtnId    { $no2 = Auto.apEdt( $no );    }    // 編集
  97.             $setBtnId    {                                // 設定
  98.                 $$USER.DEFINED.9 = list.get1st( list.getLast(
  99.                                                 list.getNth( $ApList, $no )));
  100.                 $ret = 1;
  101.                 $exitFlg = 1;
  102.             }
  103.         }
  104.  
  105.         //---   ループ終了チェック   ---//
  106.         if( $exitFlg == 1 ) {
  107.             exit;
  108.         }
  109.  
  110.         //---   リスト項目の反転項目設定   ---//
  111.         if( $no2 == #FALSE ) {
  112.             $no2 = $no;
  113.         } else {
  114.             $no = $no2;
  115.         }
  116.         if( $no > list.size( $ApList )) {
  117.             $no = list.size( $ApList );
  118.         }
  119.         list.del1st( $defList );
  120.         list.put1st( $defList, $no );
  121.     }
  122.  
  123.     //---   後始末   ---//
  124.     dialog.delButton( $newBtnId );
  125.     dialog.delButton( $selBtnId );
  126.     dialog.delButton( $delBtnId );
  127.     dialog.delButton( $edtBtnId );
  128.     dialog.delButton( $setBtnId );
  129.     dialog.delButton( $canBtnId );
  130.  
  131.     if( data.getType( $ListTrdId ) == #NUMBER ) {
  132.         trd.end( $ListTrdId );
  133.     }
  134.     sys.local( $ListTrdId );
  135.     trd.end( $TrdId );
  136.     $TrdId = #FALSE;
  137.  
  138.     sys.local( $ApList     );
  139.     sys.local( $ApDispList );
  140.  
  141.     AUTO.setDialogReturn( $ret );
  142.     return;
  143. }
  144. event    @CLOSE.EXTERN {
  145.     if( data.getType( $TrdId     ) == #NUMBER ) {
  146.         trd.end( $TrdId     );
  147.     }
  148.     if( data.getType( $ListTrdId ) == #NUMBER ) {
  149.         trd.end( $ListTrdId );
  150.     }
  151.     return;
  152. }
  153. event    @ERROR    {
  154.     local.errorFunc();
  155.     event.mainLoop();
  156. }
  157.  
  158.  
  159.  
  160. //--------------------------------------------//
  161. //---   アクセスポイント表示文字列の取得   ---//
  162. //--------------------------------------------//
  163. function    Auto.getAPdispList(
  164.     $no )                                        // 対象要素番号(-1:ALL)
  165. {
  166.     $spc     = "                ";
  167.     $cnt     = 1;
  168.     $strList = [];
  169.     foreach( $data, $ApList ) {
  170.         if(( $no != -1 )&&( $cnt != $no )) {
  171.             $cnt = $cnt + 1;
  172.             continue;
  173.         }
  174.         $list = [];
  175.  
  176.         //---   市外局番設定   ---//
  177.         $str = list.getNth( $data, 2 );
  178.         if( $str != "" ) {
  179.             list.putLast( $list, $str );
  180.             list.putLast( $list, "-" );
  181.         }
  182.  
  183.         //---   電話番号設定   ---//
  184.         $str = list.getNth( $data, 6 );
  185.         list.putLast( $list, $str );
  186.  
  187.         //---   市外局番と電話番号を繋げる   ---//
  188.         $str = str.join( $list, "" );
  189.         $len = str.length( $str );
  190.         $list = [" ", $str, "  "];
  191.         if( $len < 16 ) {
  192.             list.putLast( $list, str.left( $spc, 16 - $len ));
  193.         }
  194.  
  195.         //---   アクセスポイント名の設定   ---//
  196.         $str = list.getNth( $data, 1 );
  197.         $len = str.length( $str );
  198.         list.putLast( $list, $str );
  199.         if( $len < 12 ) {
  200.             list.putLast( $list, str.left( $spc, 12 - $len ));
  201.         }
  202.  
  203.         //---   ボーレート設定   ---//
  204.         $wkList = list.getNth( $data, 4 );
  205.         $str = list.getNth( $wkList, 1 );
  206.         if( list.size( $wkList ) > 1 ) {
  207.             $str = str.join([$str, list.getNth( $wkList, 2 )], "/" );
  208.         }
  209.         $len = str.length( $str );
  210.         if( $len < 12 ) {
  211.             list.putLast( $list, str.left( $spc, 12 - $len ));
  212.         }
  213.         list.putLast( $list, $str );
  214.         list.putLast( $list, "bps  " );
  215.  
  216.         //---   属性設定   ---//
  217.         $wkList = list.getNth( $data, 5 );
  218.         $str = "    ";
  219.         foreach( $a, $wkList ) {
  220.             if( $a == "MNP" ) {
  221.                 $str = "MNP ";
  222.                 exit;
  223.             }
  224.         }
  225.         list.putLast( $list, $str );
  226.         $str = "      ";
  227.         foreach( $a, $wkList ) {
  228.             if( $a == "INS-C" ) {
  229.                 $str = "INS-C ";
  230.                 exit;
  231.             }
  232.         }
  233.         list.putLast( $list, $str );
  234.         $str = "            ";
  235.         foreach( $a, $wkList ) {
  236.             if( $a == "CLASS10" ) {
  237.                 $str = "移動体通信  ";
  238.                 exit;
  239.             }
  240.         }
  241.         list.putLast( $list, $str );
  242.  
  243.         //---   ROAD種別の設定   ---//
  244.         list.putLast( $list, list.getNth( $data, 3 ));
  245.         list.putLast( $list, " " );
  246.  
  247.         //---   1行分の文字列作成&設定   ---//
  248.         list.putLast( $strList, str.join( $list, "" ));
  249.         if( $cnt == $no ) {
  250.             exit;
  251.         }
  252.         $cnt = $cnt + 1;
  253.     }
  254.  
  255.     return( $strList );
  256. }
  257.  
  258.  
  259.  
  260. //----------------------------------//
  261. //---   アクセスポイントの編集   ---//
  262. //----------------------------------//
  263. function    Auto.apEdt(
  264.     $selNo )                                        // 対象要素番号(-1:NEW)
  265. {
  266.     //---   現在の設定の取得   ---//
  267.     if( $selNo == -1 ) {                            // 新規の場合
  268.         $title       = "アクセスポイントの作成";
  269.         $setBtnTitle = "登録";
  270.         $town = [""];
  271.         $tel1 = [""];
  272.         $tel2 = [""];
  273.         $kind = [4];
  274.     } else {                                    // 既存のデータの場合
  275.         $title       = "アクセスポイントの編集";
  276.         $setBtnTitle = "設定";
  277.         $apList = list.getNth( $ApList, $selNo );
  278.         $town   = [list.getNth( $apList, 1 )];
  279.         $tel1   = [list.getNth( $apList, 2 )];
  280.         $tel2   = [list.getNth( $apList, 6 )];
  281.         $kind   = [list.getNth( list.getLast( $apList ), 2 )];
  282.     }
  283.     $warnDlgTitle = str.join(["━━━━━", $title, "━━━━━"],"  " );
  284.  
  285.     //---   最大登録件数のチェック   ---//
  286.     if(( $selNo == -1 )&&( list.size( $ApList ) == 64 )) {
  287.         Auto.apEdtWarn( $warnDlgTitle, 2 );
  288.         return( #FALSE );
  289.     }
  290.  
  291.     //---   ボタンの設定   ---//
  292.     $setBtnId = dialog.makeButton( 1, $setBtnTitle, 0, 0x8012 );
  293.     $canBtnId = dialog.makeButton( 1, "取消",       0, 0x8011 );
  294.  
  295.     //---   ダイアログリストの設定   ---//
  296.     $dialogList = [$title, 0, -1, -1, $setBtnId,
  297.         ["アクセスポイントの市町村名  ", 1025, [12,0],           [""],$town],
  298.         ["                  市外局番  ", 1025, [ 6,0],           [""],$tel1],
  299.         ["                  電話番号  ", 1025, [ 9,0],           [""],$tel2],
  300.         ["",                             1024,    [0],           [""], [""]],
  301.         ["アクセスポイントの種類      ", 1030,    [1],
  302.             ["ROAD1 : 300bps                    ",
  303.              "ROAD1 : 1200bps                   ",
  304.              "ROAD1 : 2400bps       (MNP)       ",
  305.              "ROAD2 : 1200/2400bps  (MNP)       ",
  306.              "ROAD3 : 9600bps       (MNP)       ",
  307.              "ROAD3 : 9600bps       (INS-C)     ",
  308.              "ROAD3 : 9600bps       (移動体通信)",
  309.              "ROAD4 : 9600/14400bps (MNP)       "],                      $kind],
  310.         ["",                             1024,    [0],           [""], [""]],
  311.         ["", $canBtnId, [0], [""], [""]],
  312.         ["", $setBtnId, [0], [""], [""]]
  313.     ];
  314.  
  315.     //---   ダイアログの表示   ---//
  316.     loop {
  317. DIALOG_OPEN:
  318. //        $saveXsize = dialog.getDefaultXSize();
  319. //        dialog.setDefaultXSize( 300 );
  320.         sys.pushCursor( 80 );
  321.         dialog.open( $dialogList );
  322.         sys.popCursor();
  323. //        dialog.setDefaultXSize( $saveXsize );
  324.  
  325.         //---   取消の場合はそのまま終了   ---//
  326.         $btnNo = list.get1st( $$DIALOG.RETURN );
  327.         if( $btnNo == $canBtnId ) {
  328.             exit;
  329.         }
  330.  
  331.         //---   データ保存   ---//
  332.         list.delNth( list.getNth( $dialogList,  6 ), 5 );
  333.         list.putNth( list.getNth( $dialogList,  6 ), 4,
  334.                                             list.getNth( $$DIALOG.RETURN, 2 ));
  335.         list.delNth( list.getNth( $dialogList,  7 ), 5 );
  336.         list.putNth( list.getNth( $dialogList,  7 ), 4,
  337.                                             list.getNth( $$DIALOG.RETURN, 3 ));
  338.         list.delNth( list.getNth( $dialogList,  8 ), 5 );
  339.         list.putNth( list.getNth( $dialogList,  8 ), 4,
  340.                                             list.getNth( $$DIALOG.RETURN, 4 ));
  341.         list.delNth( list.getNth( $dialogList, 10 ), 5 );
  342.         list.putNth( list.getNth( $dialogList, 10 ), 4,
  343.                                             list.getNth( $$DIALOG.RETURN, 6 ));
  344.  
  345.         //---   入力されたデータの正当性チェック   ---//
  346.         if( list.get1st( list.getNth($$DIALOG.RETURN, 3 )) != "" ) {
  347.             $list = str.split(list.get1st(list.getNth($$DIALOG.RETURN,3)),"");
  348.             if( list.get1st( $list ) != "0" ) {    // 市外局番の先頭は'0'固定
  349.                 Auto.apEdtWarn( $warnDlgTitle, 0 );
  350.                 continue;
  351.             }
  352.             foreach( $a, $list ) {                // 市外局番は半角数字のみ
  353.                 if(( $a < "0" )||( $a > "9" )) {
  354.                     Auto.apEdtWarn( $warnDlgTitle, 0 );
  355.                     goto DIALOG_OPEN;
  356.                 }
  357.             }
  358.         }
  359.         $list = str.split( list.get1st( list.getNth($$DIALOG.RETURN, 4)), "" );
  360.         foreach( $a, $list ) {                    // 電話番号は半角数字と"-"のみ
  361.             if((( $a < "0" )||( $a > "9" ))&&( $a != "-" )) {
  362.                 Auto.apEdtWarn( $warnDlgTitle, 1 );
  363.                 goto DIALOG_OPEN;
  364.             }
  365.         }
  366.         exit;
  367.     }
  368.  
  369.     //---   設定処理   ---//
  370.     if( $btnNo == $canBtnId ) {                    // 取消の場合
  371.         dialog.delButton( $setBtnId );
  372.         dialog.delButton( $canBtnId );
  373.         return( #FALSE );
  374.     }
  375.  
  376.     //---   ボタン削除   ---//
  377.     dialog.delButton( $setBtnId );
  378.     dialog.delButton( $canBtnId );
  379.  
  380.     if( $selNo == -1 ) {
  381.         //---   新規の場合は未使用のIDを探す   ---//
  382.         $no = 1;
  383.         loop {
  384.             $retList = trd.checkList( $TrdId, [$no, -2] );
  385.             if( list.get1st( $retList ) == 0 ) {
  386.                 exit;
  387.             }
  388.             $no = $no + 1;
  389.         }
  390.     } else {
  391.         //---   既存の物の場合は、一度グループを削除する   ---//
  392.         $no = list.get1st( list.getNth( $apList, 7 ));
  393.         trd.delData( $TrdId, [$no, -2] );
  394.     }
  395.  
  396.     //---   データを吐き出す   ---//
  397.     $kind = list.get1st( list.getNth( list.getNth( $dialogList, 10 ), 5 ));
  398.     $str  = list.get1st( list.getNth( $$DIALOG.RETURN, 2 ));
  399.     $str  = str.join([$str, "\t",
  400.                         list.get1st( list.getNth( $$DIALOG.RETURN,3 ))], "" );
  401.     trd.setData( $TrdId, [$no, -2], $str );
  402.     table( $kind ) {
  403.         1    { $str = "ROAD1";    }
  404.         2    { $str = "ROAD1";    }
  405.         3    { $str = "ROAD1";    }
  406.         4    { $str = "ROAD2";    }
  407.         5    { $str = "ROAD3";    }
  408.         6    { $str = "ROAD3";    }
  409.         7    { $str = "ROAD3";    }
  410.         8    { $str = "ROAD4";    }
  411.     }
  412.     trd.setData( $TrdId, [$no, $kind, -2], $str );
  413.     table( $kind ) {
  414.         1    { $str = "300";            }
  415.         2    { $str = "1200";        }
  416.         3    { $str = "2400";        }
  417.         4    { $str = "1200,2400";    }
  418.         5    { $str = "9600";        }
  419.         6    { $str = "9600";        }
  420.         7    { $str = "9600";        }
  421.         8    { $str = "9600,14400";    }
  422.     }
  423.     trd.setData( $TrdId, [$no, $kind, 1], $str );
  424.     table( $kind ) {
  425.         1    { $str = "";            }
  426.         2    { $str = "";            }
  427.         3    { $str = "MNP";            }
  428.         4    { $str = "MNP";            }
  429.         5    { $str = "MNP,V.32";    }
  430.         6    { $str = "INS-C";        }
  431.         7    { $str = "MNP,CLASS10";    }
  432.         8    { $str = "MNP,V.42";    }
  433.     }
  434.     trd.setData( $TrdId, [$no, $kind, 2], $str );
  435.     $str = list.get1st( list.getNth( $$DIALOG.RETURN, 4 ));
  436.     trd.setData( $TrdId, [$no, $kind, 3], $str );
  437.  
  438.     //---   内容のセーブ   ---//
  439.     trd.save( $TrdId, $Path );
  440.  
  441.     //---   リストに結果を反映する   ---//
  442.     if( $selNo == -1 ) {
  443.         $wkList = AUTO.getAPlist( $TrdId, $no );
  444.         list.putLast( $ApList,     list.get1st( $wkList ));
  445.         $selNo  = list.size( $ApList );
  446.         $wkList = Auto.getAPdispList( $selNo );
  447.         list.putLast( $ApDispList, list.get1st( $wkList ));
  448.     } else {
  449.         $wkList = AUTO.getAPlist( $TrdId, $no );
  450.         list.delNth( $ApList,     $selNo );
  451.         list.putNth( $ApList,     $selNo - 1, list.get1st( $wkList ));
  452.         $wkList = Auto.getAPdispList( $selNo );
  453.         list.delNth( $ApDispList, $selNo );
  454.         list.putNth( $ApDispList, $selNo - 1, list.get1st( $wkList ));
  455.     }
  456.     return( $selNo );
  457. }
  458.  
  459.  
  460.  
  461. //--------------------------------------------------//
  462. //---   アクセスポイントの編集エラーダイアログ   ---//
  463. //--------------------------------------------------//
  464. function    Auto.apEdtWarn(
  465.     $title,                                        // ダイアログタイトル
  466.     $no )                                        // エラー番号
  467. {
  468.     table( $no ) {
  469.         0        {
  470.             $msg = "          市外局番に誤りがあります。          ";
  471.         }
  472.         1        {
  473.             $msg = "          電話番号に誤りがあります。          ";
  474.         }
  475.         2        {
  476.             $msg = "   最大登録数を超えるため、登録出来ません。   ";
  477.         }
  478.     }
  479.     $saveXsize = dialog.getDefaultXSize();
  480.     dialog.setDefaultXSize( 300 );
  481.     sys.pushCursor( 80 );
  482.     dialog.ask([$title,"",$msg,""],["確認"]);
  483.     sys.popCursor();
  484.     dialog.setDefaultXSize( $saveXsize );
  485. }
  486.  
  487.  
  488.  
  489. //----------------------------------//
  490. //---   アクセスポイントの削除   ---//
  491. //----------------------------------//
  492. function    Auto.apDel(
  493.     $no )                                        // 削除するAPデータの要素番号
  494. {
  495.     $apList = list.getNth( $ApList, $no );
  496.  
  497.     //---   AP名を加工する   ---//
  498.     $list = ["【"];
  499.     list.putLast( $list, list.getNth( $apList, 1 ));
  500.     list.putLast( $list, " " );
  501.     $wkList = list.getNth( $apList, 4 );
  502.     list.putLast( $list, list.get1st( $wkList ));
  503.     if( list.size( $wkList ) > 1 ) {
  504.         list.putLast( $list, "/" );
  505.         list.putLast( $list, list.getNth( $wkList, 2 ));
  506.     }
  507.     list.putLast( $list, "bps " );
  508.     list.putLast( $list, list.getNth( $apList, 3 ));
  509.     list.putLast( $list, " : " );
  510.     if( list.getNth( $apList, 2 ) != "" ) {
  511.         list.putLast( $list, list.getNth( $apList, 2 ));
  512.         list.putLast( $list, "-" );
  513.     }
  514.     list.putLast( $list, list.getNth( $apList, 6 ));
  515.     list.putLast( $list, "】" );
  516.     $apName = str.join( $list, "" );
  517.  
  518.     //---   ダイアログ表示   ---//
  519.     sys.pushCursor( 80 );
  520.     $saveXsize = dialog.getDefaultXSize();
  521.     dialog.setDefaultXSize( 360 );
  522.     $ret = dialog.ask([
  523.                 "━━━━━━━   アクセスポイントの削除   ━━━━━━━",
  524.                 "",
  525.                 $apName,
  526.                 "",
  527.                 "                        のアクセスポイントを削除します。",
  528.                 ""],
  529.                 ["取消","実行"] );
  530.     sys.popCursor();
  531.     dialog.setDefaultXSize( $saveXsize );
  532.  
  533.     //---   各種処理   ---//
  534.     if( $ret == 0 ) {                            // 取消の場合
  535.         return( #FALSE );
  536.     }
  537.     //---   ファイルとリストの両方のデータを削除   ---//
  538.     trd.delData( $TrdId, [list.get1st( list.getNth( $apList, 7 )), -2] );
  539.     list.delNth( $ApList,     $no );
  540.     list.delNth( $ApDispList, $no );
  541.  
  542.     //---   ファイルの更新   ---//
  543.     trd.save( $TrdId, $Path );
  544.  
  545.     return( #TRUE );
  546. }
  547.  
  548.  
  549.  
  550. //----------------------------------//
  551. //---   アクセスポイントの登録   ---//
  552. //----------------------------------//
  553. function    Auto.apSel()
  554. {
  555.     //---   最大登録件数のチェック   ---//
  556.     if( list.size( $ApList ) == 64 ) {
  557.         Auto.apEdtWarn( "━━━━━  アクセスポイントの登録  ━━━━━", 2 );
  558.         return( #FALSE );
  559.     }
  560.  
  561.     //---   アクセスポイント一覧ファイルのオープン   ---//
  562.     if( data.getType( $ListTrdId ) != #NUMBER ) {
  563.         dialog.openProg([[],
  564.                          "",
  565.                          "  アクセスポイント一覧を読み込み中です  ",
  566.                          "",
  567.                          []], "", #FALSE );
  568.         $ListTrdId = trd.init( 1000 * 20, -1 );
  569.         sys.global( $ListTrdId );
  570.         $path = str.join([$$DIR.STANDARD, "PUBLIC\\APLIST.TRD"],"" );
  571.         trd.load( $ListTrdId, $path );
  572.         dialog.close();
  573.     }
  574.  
  575.     //---   地域選択ダイアログの表示   ---//
  576.     $apList = Auto.apSelArea( $ListTrdId );
  577.     if( $apList == #FALSE ) {                    // 取り消された
  578.         return( #FALSE );
  579.     }
  580.  
  581.     //---   登録アクセスポイントファイルの未使用IDを検索   ---//
  582.     $no = 1;
  583.     loop {
  584.         $retList = trd.checkList( $TrdId, [$no, -2] );
  585.         if( list.get1st( $retList ) == 0 ) {
  586.             exit;
  587.         }
  588.         $no = $no + 1;
  589.     }
  590.     $kind = list.getLast( $apList );
  591.  
  592.     //---   登録アクセスポイントファイルにデータを吐き出す   ---//
  593.     trd.setData( $TrdId, [$no, -2],        list.getNth( $apList, 1 ));
  594.     trd.setData( $TrdId, [$no, $kind, -2], list.getNth( $apList, 2 ));
  595.     trd.setData( $TrdId, [$no, $kind,  1], list.getNth( $apList, 3 ));
  596.     trd.setData( $TrdId, [$no, $kind,  2], list.getNth( $apList, 5 ));
  597.     trd.setData( $TrdId, [$no, $kind,  3], list.getNth( $apList, 4 ));
  598.     trd.save( $TrdId, $Path );
  599.  
  600.     //---   リストに結果を反映する   ---//
  601.     $wkList = AUTO.getAPlist( $TrdId, $no );
  602.     list.putLast( $ApList,     list.get1st( $wkList ));
  603.     $no     = list.size( $ApList );
  604.     $wkList = Auto.getAPdispList( $no );
  605.     list.putLast( $ApDispList, list.get1st( $wkList ));
  606.     return( $no );
  607. }
  608.  
  609.  
  610.  
  611. //------------------------------------//
  612. //---   地域選択ダイアログの処理   ---//
  613. //------------------------------------//
  614. function    Auto.apSelArea(
  615.     $trdId )                                    // AP一覧ファイルのTRD識別子
  616. {
  617.     //---   トップレベルのグループを読み込む   ---//
  618.     $areaList = [];
  619.     $tagList  = [];
  620.     $tag      = [-5,-2];
  621.     loop {
  622.         $retList = trd.getData( $trdId, $tag );
  623.         if( list.get1st( $retList ) == 0 ) {
  624.             exit;
  625.         }
  626.         list.putLast( $areaList, list.getNth( $retList, 2 ));
  627.         list.putLast( $tagList,  list.getNth( list.getLast( $retList ), 1 ));
  628.         $tag = [];
  629.     }
  630.  
  631.     //---   ボタンの設定   ---//
  632.     $setBtnId = dialog.makeButton( 1, "選択", 0, 0x8012 );
  633.     $canBtnId = dialog.makeButton( 1, "取消", 0, 0x8011 );
  634.  
  635.     //---   ダイアログリストの設定   ---//
  636.     $defList = [1];
  637.     $dialogList = ["アクセスポイントの市外局番選択", 0, -1, -1, $setBtnId,
  638.         ["", 1028,      [40,9,0], $areaList, $defList],
  639.         ["", $canBtnId, [0],      [""],      [""]    ],
  640.         ["", $setBtnId, [0],      [""],      [""]    ]
  641.     ];
  642.  
  643.     //---   ダイアログの表示   ---//
  644. DIALOG_OPEN:
  645.     $saveXsize = dialog.getDefaultXSize();
  646.     dialog.setDefaultXSize( 300 );
  647.     sys.pushCursor( 80 );
  648.     dialog.open( $dialogList );
  649.     sys.popCursor();
  650.     dialog.setDefaultXSize( $saveXsize );
  651.  
  652.     //---   取消の場合   ---//
  653.     if( list.get1st( $$DIALOG.RETURN ) == $canBtnId ) {
  654.         dialog.delButton( $setBtnId );
  655.         dialog.delButton( $canBtnId );
  656.         return( #FALSE );
  657.     }
  658.  
  659.     //---   選択された項目に対応するタグ番号を取得   ---//
  660.     $no = list.get1st( list.getNth( $$DIALOG.RETURN, 2 ));
  661.     if( $no == 0 ) {                            // 選択されていない
  662.         goto DIALOG_OPEN;
  663.     }
  664.     list.del1st( $defList );
  665.     list.put1st( $defList, $no );
  666.  
  667.     //---   アクセスポイント選択その1ダイアログの表示   ---//
  668.     $ret = Auto.apSelAP1( $ListTrdId, list.getNth( $tagList, $no ));
  669.     if( $ret == #FALSE ) {                        // 取り消された
  670.         goto DIALOG_OPEN;
  671.     }
  672.  
  673.     //---   ボタンの削除   ---//
  674.     dialog.delButton( $setBtnId );
  675.     dialog.delButton( $canBtnId );
  676.  
  677.     return( $ret );
  678. }
  679.  
  680.  
  681.  
  682. //--------------------------------------------//
  683. //---   登録アクセスポイントの選択その1   ---//
  684. //--------------------------------------------//
  685. function    Auto.apSelAP1(
  686.     $trdId,                                        // AP一覧ファイルのTRD識別子
  687.     $tagNo )                                    // 対象タググループNo.
  688. {
  689.     $spc      = "                              ";
  690.     $tagTop   = [$tagNo, -5, -2];
  691.     $tagList  = [];
  692.     $areaList = [];
  693.     loop {
  694.         $retList = trd.getData( $trdId, $tagTop );
  695.         if( list.get1st( $retList ) == 0 ) {
  696.             exit;
  697.         }
  698.         //---   アクセスポイント名と市外局番の取り出し   ---//
  699.         $apStr   = list.getNth( $retList, 2 );
  700.         $strList = str.split( $apStr, "\t" );
  701.         $apName  = list.getNth( $strList, 1 );
  702.         $townNo  = list.getNth( $strList, 2 );
  703.  
  704.         //---   対象のタグ番号の設定   ---//
  705.         list.putLast( $tagList, list.getNth( list.getLast( $retList ), 2 ));
  706.  
  707.         //---   リスト表示文字列の設定   ---//
  708.         $list = [$townNo];
  709.         $len  = str.length( $townNo );
  710.         if( $len < 28 ) {
  711.             list.putLast( $list, str.left( $spc, 28 - $len ));
  712.         }
  713.         $len  = str.length( $apName );
  714.         if( $len < 12 ) {
  715.             list.putLast( $list, str.left( $spc, 12 - $len ));
  716.         }
  717.         list.putLast( $list, $apName );
  718.         list.putLast( $areaList, str.join( $list, "" ));
  719.  
  720.         $tagTop = [];
  721.     }
  722.  
  723.     //---   ボタンの設定   ---//
  724.     $setBtnId = dialog.makeButton( 1, "選択", 0, 0x8012 );
  725.     $canBtnId = dialog.makeButton( 1, "取消", 0, 0x8011 );
  726.  
  727.     //---   ダイアログリストの設定   ---//
  728.     $defList = [1];
  729.     $dialogList = ["アクセスポイントの選択", 0, -1, -1, $setBtnId,
  730.         ["", 1028,      [40,10,0], $areaList,   $defList],
  731.         ["", $canBtnId, [0],       [""],        [""]    ],
  732.         ["", $setBtnId, [0],       [""],        [""]    ]
  733.     ];
  734.  
  735.     //---   ダイアログの表示   ---//
  736. DIALOG_OPEN:
  737.     sys.pushCursor( 80 );
  738.     dialog.open( $dialogList );
  739.     sys.popCursor();
  740.  
  741.     //---   取消の場合   ---//
  742.     if( list.get1st( $$DIALOG.RETURN ) == $canBtnId ) {
  743.         dialog.delButton( $setBtnId );
  744.         dialog.delButton( $canBtnId );
  745.         return( #FALSE );
  746.     }
  747.  
  748.     //---   選択された項目に対応するデータリストを返す   ---//
  749.     $no = list.get1st( list.getNth( $$DIALOG.RETURN, 2 ));
  750.     if( $no == 0 ) {                            // 選択されていない
  751.         goto DIALOG_OPEN;
  752.     }
  753.     list.del1st( $defList );
  754.     list.put1st( $defList, $no );
  755.  
  756.     //---   アクセスポイント選択その2ダイアログの表示   ---//
  757.     $ret = Auto.apSelAP2( $ListTrdId,[$tagNo,list.getNth($tagList,$no),-2] );
  758.     if( $ret == #FALSE ) {                        // 取り消された
  759.         goto DIALOG_OPEN;
  760.     }
  761.  
  762.     //---   ボタンの削除   ---//
  763.     dialog.delButton( $setBtnId );
  764.     dialog.delButton( $canBtnId );
  765.  
  766.     return( $ret );
  767. }
  768.  
  769.  
  770.  
  771. //--------------------------------------------//
  772. //---   登録アクセスポイントの選択その2   ---//
  773. //--------------------------------------------//
  774. function    Auto.apSelAP2(
  775.     $trdId,                                        // AP一覧ファイルのTRD識別子
  776.     $tagTop )                                    // 対象グループタグ
  777. {
  778.     //---   まずはデータの読み込み   ---//
  779.     $apList1 = [];
  780.     $apList2 = [];
  781.     $retList = trd.getData( $trdId, $tagTop );
  782.     if( list.get1st( $retList ) == 0 ) {
  783.         exit;
  784.     }
  785.  
  786.     //---   アクセスポイント名と市外局番の取り出し   ---//
  787.     $apStr   = list.getNth( $retList, 2 );
  788.     $strList = str.split( $apStr, "\t" );
  789.     $apName  = list.getNth( $strList, 1 );
  790.     $townNo  = list.getNth( $strList, 2 );
  791.  
  792.     //---   詳細情報の読み込み   ---//
  793.     $tagSub = list.getLast( $retList );
  794.     list.delNth( $tagSub, 3 );
  795.     list.putNth( $tagSub, 2, -6 );
  796.     loop {
  797.         $retList = trd.getData( $trdId, $tagSub );
  798.         if( list.get1st( $retList ) == 0 ) {
  799.             exit;
  800.         }
  801.  
  802.         //---   詳細情報を分解して各要素毎のリストを作る   ---//
  803.         $list = str.split( list.getNth( $retList, 2 ), "\t" );
  804.         list.put1st( $list, $apStr );
  805.         if( list.size( $list ) < 5 ) { 
  806.             list.putLast( $list, "" );
  807.         }
  808.         list.putLast( $list, list.getNth( list.getLast( $retList ), 3 ));
  809.         list.putLast( $apList1, $list );
  810.  
  811.         $strList = str.split( list.getNth( $retList, 2 ), "\t" );
  812.         $list = [];
  813.         list.putLast( $list, $apName );
  814.         list.putLast( $list, $townNo );
  815.         list.putLast( $list, list.getNth( $strList, 1 ));
  816.         list.putLast( $list, str.split( list.getNth( $strList, 2 ), "," ));
  817.         if( list.size( $strList ) > 3 ) {
  818.             list.putLast( $list,str.split(list.getNth($strList, 4), "," ));
  819.         } else {
  820.             list.putLast( $list, [] );
  821.         }
  822.         list.putLast( $list, list.getNth( $strList, 3 ));
  823.         list.putLast( $list, 0 );
  824.         list.putLast( $apList2, $list );
  825.  
  826.         $tagSub = [];
  827.     }
  828.  
  829.     //---   リストに表示する文字列を取得する   ---//
  830.     $apListSave = $ApList;
  831.     $ApList     = $apList2;
  832.     $dispList   = Auto.getAPdispList( -1 );
  833.     $ApList     = $apListSave;
  834.     dialog.close();
  835.  
  836.     //---   ボタンの設定   ---//
  837.     $setBtnId = dialog.makeButton( 1, "選択", 0, 0x8012 );
  838.     $canBtnId = dialog.makeButton( 1, "取消", 0, 0x8011 );
  839.  
  840.     //---   ダイアログリストの設定   ---//
  841.     $dialogList = ["アクセスポイントの選択", 0, -1, -1, $setBtnId,
  842.         ["", 1028,      [76,10,0], $dispList,    [1]],
  843.         ["", $canBtnId, [0],       [""],        [""]],
  844.         ["", $setBtnId, [0],       [""],        [""]]
  845.     ];
  846.  
  847.     //---   ダイアログの表示   ---//
  848. DIALOG_OPEN:
  849.     sys.pushCursor( 80 );
  850.     dialog.open( $dialogList );
  851.     sys.popCursor();
  852.  
  853.     //---   取消の場合   ---//
  854.     if( list.get1st( $$DIALOG.RETURN ) == $canBtnId ) {
  855.         dialog.delButton( $setBtnId );
  856.         dialog.delButton( $canBtnId );
  857.         return( #FALSE );
  858.     }
  859.  
  860.     //---   選択された項目に対応するデータリストを返す   ---//
  861.     $no = list.get1st( list.getNth( $$DIALOG.RETURN, 2 ));
  862.     if( $no == 0 ) {                            // 選択されていない
  863.         goto DIALOG_OPEN;
  864.     }
  865.  
  866.     //---   ボタンの削除   ---//
  867.     dialog.delButton( $setBtnId );
  868.     dialog.delButton( $canBtnId );
  869.  
  870.     return( list.getNth( $apList1, $no ));
  871. }
  872.